package com.yzy.fly.mapper;

import com.yzy.fly.entity.role.FlyModelWidget;
import com.yzy.fly.kernel.mapper.FlyBasicMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

@Mapper
public interface FlyModelWidgetMapper extends FlyBasicMapper<FlyModelWidget> {

    @Select("select * from fly_model_widget a where 1=1 ")
    List<FlyModelWidget> selectAllList();

    @Select("select * from fly_model_widget a where 1=1 and a.modelId = #{modelId}")
    FlyModelWidget selectByModelId(@Param("modelId") Integer modelId);

    @Select("select * from fly_model_widget a where 1=1 and a.systemId = #{systemId}")
    List<FlyModelWidget> selectAllBySystemId(@Param("systemId") Integer systemId);

    @Select("select * from fly_model_widget a where 1=1 and a.parentId = #{parentId} and a.systemId = #{systemId}")
    List<FlyModelWidget> selectAllByParentIdAndSystemId(@Param("parentId") Integer parentId, @Param("systemId") Integer systemId);

    @Select("select * from fly_model_widget a where 1=1 and (a.id = #{parentId} or a.parentId = #{parentId}) and a.systemId = #{systemId}")
    List<FlyModelWidget> selectAllByParentIdAndSystemId_ContainsId(@Param("parentId") Integer parentId, @Param("systemId") Integer systemId);

    @Select("select * from fly_model_widget a where 1=1 and a.defModelId = #{defModelId} and a.systemId = #{systemId}")
    List<FlyModelWidget> selectAllByDefIdIdAndSystemId(@Param("defModelId") Integer defModelId, @Param("systemId") Integer systemId);

    /**
     * 批量插入（mysql）
     * @param entityList
     * @return
     */
    Integer insertBatchSomeColumn(Collection<FlyModelWidget> entityList);

}
